package test_pkg

import (
	"fmt"
	"time"
)

// 协程初见
func shortWait() {
	fmt.Println("shortWait start")
	time.Sleep(2 * time.Second)
	fmt.Println("shortWait end")
}

func longWait() {
	fmt.Println("longWait start")
	time.Sleep(5 * time.Second)
	fmt.Println("longWait end")
}

func Test_goroutine1() {
	fmt.Println("In main()")
	//这里的协程是独立执行的，之间没有通信
	go longWait()
	go shortWait()
	fmt.Println("About to sleep in Test()")
	// sleep works with a Duration in nanoseconds (ns) !
	time.Sleep(10 * time.Second)
	fmt.Println("At the end of Test()")
}
